package com.gofun.framework.dubbo.core.environment.config;

import com.gofun.framework.dubbo.core.environment.ConfigMapping;
import com.gofun.framework.dubbo.core.environment.ResolveMappingStrategy;
import com.gofun.framework.dubbo.core.environment.DefaultResolveStrategy.ResolveStrategyEnum;

/**
 * @Project       : framework-dubbo-core
 * @Program Name  : com.ljt.framework.dubbo.core.environment.property.ConsumerConfigEnum.java
 * @Description   : <dubbo:consumer/> 服务消费者默认配置
 * @Author        : wangchao
 * @Creation Date : 2016年5月27日 下午4:04:50 
 * @ModificationHistory  
 * Who          When             What 
 * ----------   -------------    -----------------------------------
 * wangchao     2016年5月27日        create
 */
public enum ConsumerConfigEnum implements ConfigMapping {
	
	TIMEOUT("dubbo.consumer.timeout","远程服务调用超时时间(毫秒),默认1000"),
	
	RETRIES("dubbo.consumer.retries","远程服务调用重试次数，不包括第一次调用，不需要重试请设为0，默认2"),
	
	LOADBALANCE("dubbo.consumer.loadbalance","负载均衡策略，可选值：random,roundrobin,leastactive，分别表示：随机，轮循，最少活跃调用；默认random"),
	
	OWNER("dubbo.consumer.owner","调用服务负责人，用于服务治理，请填写负责人公司邮箱前缀"),
	
	CHECK("dubbo.consumer.check","启动时检查提供者是否存在，true报错，false忽略,默认true"),
	;
	
	public String code;
	
	public String text;
	
	public String[] activated; 
	
	public ResolveMappingStrategy resolveMapping;
	
	private ConsumerConfigEnum(String code,String text) {
		this(code, text,ResolveStrategyEnum.DIRECT.resolve, ALL_ACTIVATED);
	}
	
	private ConsumerConfigEnum(String code,String text,String... activated) {
		this(code, text, ResolveStrategyEnum.DIRECT.resolve, activated);
	}
	
	private ConsumerConfigEnum(String code,String text,ResolveMappingStrategy resolveMapping,String... activated) {
		this.code = code;
		this.text = text;
		this.activated = activated;
		this.resolveMapping = resolveMapping;
	}
	
	@Override
	public ResolveMappingStrategy getResolveMapping() {
		return resolveMapping;
	}
	
	public String[] getActivated() {
		return activated;
	}
	
	@Override
	public String getCode() {
		return code;
	}

	@Override
	public String getText() {
		return text;
	}

}
